package com.bytedance.ttnet;

import com.bytedance.frameworks.baselib.network.http.b.a.SsOkHttp3Client;
import com.bytedance.frameworks.baselib.network.http.cronet.a.SsCronetHttpClient;
import com.bytedance.retrofit2.client.Client;
import com.bytedance.retrofit2.client.Request;
import com.bytedance.retrofit2.client.ClientCall;

import java.io.IOException;

public final class aa {
    static final c a = new c((byte) 0);
    static boolean b = false;
    static String c;
    private static b d;
    private static a$a e = new a$a((byte) 0);

    public static void a(b arg0) {
        aa.d = arg0;
    }

    public static boolean a() {
        return aa.d != null && aa.d.e() && cc.a().isCronetInstalled() && (!aa.b);
    }

    public static Client b() {
        Client client = aa.a() ? aa.e.a() : aa.a.a();
        return client;
    }

    public interface b {
        boolean e();
    }

    static final class a$a extends c {
        a$a(byte arg1) {
            this();
        }

        private a$a() {
            super((byte) 0);
        }

        public final Client a() {
            return a$d.a(SsCronetHttpClient.getInstance(com.bytedance.ttnet.cc.a().getContext()));
        }
    }

    static class c {
        c(byte arg1) {
            this();
        }

        private c() {

        }

        public Client a() {
            return SsOkHttp3Client.getInstance(com.bytedance.ttnet.cc.a().getContext());
        }
    }

    static class a$d implements Client {
        private static volatile a$d a;
        private SsCronetHttpClient b;

        private a$d(SsCronetHttpClient arg1) {
            this.b = arg1;
        }

        public static a$d a(SsCronetHttpClient arg2) {
            if (a == null) {
                synchronized (NetworkAsyncInitThread.class) {
                    if (a == null) {
                        a = new a$d(arg2);
                    }
                }
            }

            return a;
        }

        public final ClientCall execute(Request request) throws IOException {
            ClientCall v0_1;
            try {
                v0_1 = this.b.execute(request);
            } catch (Throwable v0) {
                aa.b = true;
                aa.c = android.support.design.a.b(v0);
                v0_1 = aa.a.a().execute(request);
            }

            return v0_1;
        }
    }
}

